<template>
<!-- 审核车辆 -->
  <div class="vehicleAudit">
    <el-card shadow="never" style="margin-top: 30px">
      <div class="header">
        <div class="page-header">
          <el-page-header @back="goBack" content="审核车辆" style="margin-bottom: 20px">
          </el-page-header>
        </div>
      </div>

      <div class="vehicleApplyForm">
        <el-form :model="vehicleApplyForm" ref="activityRuleForm" label-width="120px" class="demo-ruleForm" size="mini">
          <el-form-item label="车主姓名" prop="veName" >
            <el-input v-model="vehicleApplyForm.veName" :disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="业务类型" prop="veType">
            <el-select v-model="vehicleApplyForm.veType" placeholder="请选择业务类型" :disabled="true">
              <el-option label="免费" value="0"></el-option>
              <el-option label="月租" value="1"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="车牌号" prop="veNumber" >
            <el-input v-model="vehicleApplyForm.veNumber" :disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="审核意见" prop="approStatus">
          <el-select v-model="vehicleApprovalForm.approStatus" placeholder="请选择审核意见">
            <el-option label="通过" value="1"></el-option>
            <el-option label="不通过" value="0"></el-option>
          </el-select>
        </el-form-item>
          <el-form-item label="审核备注" prop="approNote">
            <el-input type="textarea" v-model="vehicleApprovalForm.approNote" ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="addVehicleApproval">确认</el-button>
          </el-form-item>
        </el-form>
      </div>



    </el-card>
  </div>
</template>

<script>
import {addVehicleApproval, getVehicleApplyById} from "@/api/allApi";

export default {
  name: "index",
  data(){
    return {
      admin:'',
      vehicleApplyForm:{},
      vehicleApprovalForm:{},
    }
  },
  created() {
    this.admin = JSON.parse(window.localStorage.getItem('access-admin'))
  },
  methods: {
    goBack() {
      this.$router.back();
    },
    getVehicleApplyById(){
      getVehicleApplyById(this.$route.params.veApplyId).then(res=>{{
        this.vehicleApplyForm = res.data.data
      }})
    },
    addVehicleApproval(){
      this.vehicleApprovalForm.veApplyId = this.vehicleApplyForm.veApplyId
      this.vehicleApprovalForm.adminId = this.admin.adminId
      addVehicleApproval(this.vehicleApprovalForm).then(res=>{
        if (res.data.success){
          this.$message.success(res.data.data)
          this.$router.push({path:'/adminLayout/adminBackground/pendingVehicle'})
        }else {
          this.$message.error("审批失败")
        }
      })
    }
  },
  mounted() {
    this.getVehicleApplyById()
  }
}
</script>

<style lang="less" scoped>
.vehicleApplyForm {
  width: 800px;
  padding: 30px;

}
</style>